package com.edfu.core.contentmgt.jcr.service.impl;

import com.edfu.core.contentmgt.jcr.exception.JCRBeanLocatorException;

public class JCRBeanLocatorUtil {

	public static Object locateBean(String className) {
		@SuppressWarnings("rawtypes")
		Class cls = null;
		Object instance = null ;
		Thread currentThread = Thread.currentThread();
		ClassLoader contextClassLoader = currentThread.getContextClassLoader();
		try {
			cls = contextClassLoader.loadClass(className);
			instance = cls.newInstance() ;
		} catch (ClassNotFoundException e) {
			throw new JCRBeanLocatorException(e.getMessage());
		} catch (InstantiationException e) {
			throw new JCRBeanLocatorException(e.getMessage());
		} catch (IllegalAccessException e) {
			throw new JCRBeanLocatorException(e.getMessage());
		}
		
		return instance;
	}

}
